/*******************************************************************************
 ** Name: cmd.cpp                                                             **
 ** Description: WorldObject-derived container objects                        **
 **                                                                           **
 ** Open Source Initiative (OSI) Approved License                             **
 **                                                                           **
 ** The contents of this file are subject to the terms of the                 **
 ** Common Development and Distribution License, Version 1.0 only             **
 ** (the "License").  You may not use this file except in compliance          **
 ** with the License.                                                         **
 **                                                                           **
 ** You can find a copy of the license in the LICENSE file within             **
 ** this distribution or at $WIKI/display/GOVT/License-software.              **
 ** Software distributed under the License is distributed on an "AS IS"       **
 ** basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.           **
 ** See the License for the specific language governing permissions           **
 ** and limitations under the License.                                        **
 **                                                                           **
 ** When distributing Covered Code, include this CDDL header in each          **
 ** file and include the License file at $GAME_DIR/LICENSE.                   **
 ** If applicable, add the following below this header, with the indicated    **
 ** fields enclosed by brackets "[]" replaced with your own identifying       **
 ** information: Portions Copyright [yyyy] [name of copyright owner]          **
 **                                                                           **
 ** Copyright (c) 2009-2011  Barry Gian James <gian@gamingods.net>            **
 ** All rights reserved.                                                      **
 ******************************************************************************/
// Portions (c) 2012 Open Design Strategies, LLC.
// Modified $Date: 2012-08-14 20:47:30 -0600 (Tue, 14 Aug 2012) $ by $Author: unknown $

#define _cmd_cpp_ID    "$Id: cmd.cpp 69068 2012-08-15 02:47:30Z unknown $"
#include <vector>
#include "cmd.hpp"
#include "object.hpp"

Command::Command()
{
	_idcommand = 0;
	_idcategory = 0;
	_cost = 0;
	_access = 0;
	_flags = 0;
	_enabled = true;
	_priority = CmdPriority::Normal;
	_source = "";
}

Command::Command(const Command & o)
{
	Command & other = const_cast<Command&>(o);
	_idcommand = other.ID();
	_name = other.Name();
	_desc = other.Desc();
	_example = other.Example();
	_help = other.Help();
	_syntax = other.Syntax();
	_type = other.Type();
	_priority = other.Priority();
	_idcategory = other.Category();
	_cost = other.Cost();
	_access = other.Access();
	_flags = other.Flags();
	_enabled = other.Enabled();
	_source = other.Source();
}

CmdReturn
Command::Execute(std::string & a)
{

	return CmdReturn::Unknown;
}

// Operators
//Command &
//Command::operator = (const Command & c)
//{
//	this->Command(c);
//	return *this;
//}

bool
Command::operator == (const Command & c)
{
	return( _idcommand == c.ID() );
}

bool
Command::operator != (const Command & c)
{
	return( _idcommand != c.ID() );
}


namespace cmd
{
std::vector<std::string> articles;
std::map<std::string,Command::pointer> commands;
std::queue<std::string> cmd_queue;

void process()
{
	while(!cmd_queue.empty())
	{
		std::string preproc = cmd_queue.pop();
		size_t pos = preproc.find_first_of(' ');
		cmdfunc cmd_req = commands[preproc.substr(0,pos)];

		if (!cmd_req(preproc) == CmdReturn::OK)
		{
			// TODO have to see what happened

		}
	}


}

void add_to_queue(std::string & c)
{
	cmd_queue.push(c);
}

int init()
{
	articles.push_back("a");
	articles.push_back("an");
	articles.push_back("the");

	// TODO Load default commands from db
	commands["look"] = cmd_look;
	commands["give"] = cmd_give;
	commands["take"] = cmd_take;
	commands["say"] = cmd_say;
	commands["tell"] = cmd_tell;
	commands["drop"] = cmd_drop;
	commands["wield"] = cmd_wield;
	commands["unwield"] = cmd_unwield;
	commands["put"] = cmd_put;
	commands["attack"] = cmd_attack;
	commands["cast"] = cmd_cast;
	commands["go"] = cmd_go;
	commands["character"] = cmd_character;
	commands["inventory"] = cmd_inventory;
	commands["skills"] =cmd_skills;
	commands["faction"] = cmd_faction;
	commands["ask"] = cmd_ask;
	commands["buy"] = cmd_buy;
	commands["climb"] = cmd_climb;
	commands["cover"] = cmd_cover;
	commands["crouch"] = cmd_crouch;
	commands["draw"] = cmd_draw;
	commands["duel"] = cmd_duel;
	commands["emote"] = cmd_emote;
	commands["enter"] = cmd_enter;
	commands["examine"] = cmd_examine;
	commands["follow"] = cmd_follow;
	commands["me"] = cmd_me;
	commands["open"] = cmd_open;
	commands["pick"] = cmd_pick;
	commands["push"] = cmd_push;
	commands["recite"] = cmd_recite;
	commands["read"] = cmd_read;
	commands["remove"] = cmd_remove;
	commands["repair"] = cmd_repair;
	commands["sell"] = cmd_sell;
	commands["shout"] = cmd_shout;
	commands["show"] = cmd_show;
	commands["sit"] = cmd_sit;
	commands["stand"] = cmd_stand;
	commands["throw"] = cmd_throw;
	commands["unwear"] = cmd_unwear;
	commands["turn"] = cmd_turn;
	commands["unload"] = cmd_unload;
	commands["load"] = cmd_load;
	commands["unlock"] = cmd_unlock;
	commands["wear"] = cmd_wear;
	commands["about"] = cmd_about;
	commands["account"] = cmd_account;
	commands["afk"] = cmd_afk;
	commands["agency"] = cmd_agency;
	commands["assignments"] = cmd_assignments;
	commands["autoloot"] = cmd_autoloot;
	commands["awards"] = cmd_awards;
	commands["background"] = cmd_background;
	commands["bug"] = cmd_bug;
	commands["callcontrol"] = cmd_callcontrol;
	commands["commands"] = cmd_commands;
	commands["cooldowns"] = cmd_cooldowns;
	commands["coordinates"] = cmd_coordinates;
	commands["disband"] = cmd_disband;
	commands["dossier"] = cmd_dossier;
	commands["down"] = cmd_down;
	commands["east"] = cmd_east;
	commands["west"] = cmd_west;
	commands["north"] = cmd_north;
	commands["n"] = cmd_north;
	commands["d"] = cmd_down;
	commands["e"] = cmd_east;
	commands["w"] = cmd_west;
	commands["s"] = cmd_south;
	commands["south"] = cmd_south;
	commands["i"] = cmd_inventory;
	commands["u"] = cmd_up;
	commands["up"] = cmd_up;
	commands["ne"] = cmd_ne;
	commands["nw"] = cmd_nw;
	commands["se"] = cmd_se;
	commands["sw"] = cmd_sw;
	commands["conditions"] = cmd_conditions;
	commands["emotes"] = cmd_emotes;
	commands["entrances"] = cmd_entrances;
	commands["exits"] = cmd_exits;
	commands["faq"] = cmd_faq;
	commands["friends"] = cmd_friends;
	commands["help"] = cmd_help;
	commands["history"] = cmd_history;
	commands["idea"] = cmd_idea;
	commands["last"] = cmd_last;
	commands["listen"] = cmd_listen;
	commands["log"] = cmd_log;
	commands["mail"] = cmd_mail;
	commands["news"] = cmd_news;
	commands["occupation"] = cmd_occupation;
	commands["profession"] = cmd_profession;
	commands["quit"] = cmd_quit;
	commands["logout"] = cmd_logout;
	commands["reboot"] = cmd_reboot;
	commands["rest"] = cmd_rest;
	commands["save"] = cmd_save;
	commands["shutdown"] = cmd_shutdown;
	commands["socials"] = cmd_socials;
	commands["spells"] = cmd_spells;
	commands["stats"] = cmd_stats;
	commands["tasks"] = cmd_tasks;
	commands["team"] = cmd_team;
	commands["train"] = cmd_train;
	commands["title"] = cmd_title;
	commands["uptime"] = cmd_uptime;
	commands["users"] = cmd_users;
	commands["version"] = cmd_version;
	commands["who"] = cmd_who;
	commands["reghelper"] = cmd_reghelper;
	commands["jargon"] = cmd_jargon;
	commands["describe"] = cmd_describe;
	commands["wallops"] = cmd_wallops;
	commands["wall"] = cmd_wall;
	commands["ban"] = cmd_ban;
	commands["consider"] = cmd_consider;
	commands["finger"] = cmd_finger;
	commands["ignore"] = cmd_ignore;
	commands["invite"] = cmd_invite;
	commands["locate"] = cmd_locate;
	commands["seen"] = cmd_seen;
	commands["talents"] = cmd_talents;
	commands["run"] = cmd_run;
	commands["dump"] = cmd_dump;
	commands["list"] = cmd_list;
	commands["area"] = cmd_area;
	commands["bounty"] = cmd_bounty;
	commands["channel"] = cmd_channel;
	commands["client"] = cmd_client;
	commands["message"] = cmd_message;
	commands["module"] = cmd_module;
	commands["npc"] = cmd_npc;
	commands["room"] = cmd_room;
	commands["object"] = cmd_object;
	commands["shop"] = cmd_shop;
	commands["door"] = cmd_door;
	commands["giveitem"] = cmd_giveitem;

	// Load commands specified in Haxe

	return 1;
}



}	/* namespace cmd */

//////////////////////////////[ Supported Commands in C++
//[Predicates
CmdReturn cmd_take(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_logout(std::string & args)
{
	return CmdReturn::OK;
}


CmdReturn cmd_give(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_ask(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_buy(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_climb(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_cover(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_crouch(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_draw(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_duel(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_emote(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_enter(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_examine(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_follow(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_me(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_open(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_pick(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_push(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_recite(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_read(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_remove(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_repair(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_sell(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_shout(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_show(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_sit(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_stand(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_look(std::string & args)
{
//	if (args == "" && obj->IsPC())
//		obj->LocationObject()->Cmd("look",obj,"");

	return CmdReturn::OK;
}

CmdReturn cmd_throw(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_unwear(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_turn(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_unload(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_load(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_unlock(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_unwield(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_wear(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_say(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_tell(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_drop(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_wield(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_doing(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_put(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_go(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_cast(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_attack(std::string & args)
{
	return CmdReturn::OK;
}

//[Commands
CmdReturn cmd_character(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_skills(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_faction(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_inventory(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_about(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_account(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_afk(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_agency(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_assignments(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_autoloot(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_awards(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_background(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_bug(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_callcontrol(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_commands(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_cooldowns(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_coordinates(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_disband(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_dossier(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_down(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_east(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_west(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_south(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_north(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_up(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_ne(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_nw(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_se(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_sw(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_conditions(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_emotes(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_entrances(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_exits(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_faq(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_friends(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_help(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_history(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_idea(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_last(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_listen(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_log(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_mail(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_news(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_occupation(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_profession(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_quit(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_reboot(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_rest(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_save(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_shutdown(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_socials(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_spells(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_stats(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_tasks(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_team(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_train(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_title(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_uptime(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_users(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_version(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_who(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_reghelper(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_jargon(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_describe(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_wallops(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_wall(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_ban(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_consider(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_finger(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_ignore(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_invite(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_locate(std::string & args)
{
	return CmdReturn::OK;
}
CmdReturn cmd_seen(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_talents(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_run(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_dump(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_list(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_area(std::string & args)
{
	return CmdReturn::OK;
}
CmdReturn cmd_bounty(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_channel(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_client(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_message(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_module(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_npc(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_room(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_object(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_shop(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_door(std::string & args)
{
	return CmdReturn::OK;
}

CmdReturn cmd_giveitem(std::string & args)
{
	return CmdReturn::OK;
}















